//
//  RetweetedStatusCell.swift
//  Weibo10
//
//  Created by 刘俊 on 15/10/22.
//  Copyright © 2015年 itheima. All rights reserved.
//

import UIKit
/*
在修改一个已有完整功能的类时需要在修改之前提交代码,之后确定对源类没有过多的影响
测试新继承的子类对父类是否有影响
check list
1,修改注册Cell
2,修改数据源方法
3,修改行高
*/
// 转发微博自定义Cell
class RetweetedStatusCell: StatusCell {

    /// 微博视图模型
    override var viewModle: StatusViewModel? {
        didSet {
            retweetedLable.text = viewModle?.retweetedStatusText
            pictureView.snp_updateConstraints { (make) -> Void in
                let offset = viewModle?.thumbnailUrls?.count > 0 ? StatusCellMargin : 0
                make.top.equalTo(retweetedLable.snp_bottom).offset(offset)
                }
            }
    }
    //MARK: - 懒加载控件
    // 背景按钮
    private lazy var backButton: UIButton = {
        let button = UIButton()
        button.backgroundColor = UIColor(white: 0.95, alpha: 1)
        
        return button
    }()
    // 转发文字
    private lazy var retweetedLable:UILabel = UILabel(title: "王晓晨王晓晨王晓晨王晓晨王晓晨王晓晨王晓晨王晓晨王晓晨王晓晨王晓晨王晓晨王晓晨王晓晨王晓晨王晓晨王晓晨王晓晨王晓晨王晓晨", fontSize: 14, color: UIColor.darkGrayColor(), screenInset: StatusCellMargin)

}
// MARK: - 设置界面
extension RetweetedStatusCell {

    override func setupUI() {
        super.setupUI()
        // 添加控件
        contentView.insertSubview(backButton, belowSubview: pictureView)
        contentView.insertSubview(retweetedLable, aboveSubview: backButton)
        // 设置约束
        backButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(contentLable.snp_bottom).offset(StatusCellMargin)
            make.left.equalTo(contentView.snp_left)
            make.right.equalTo(contentView.snp_right)
            make.bottom.equalTo(bottomView.snp_top).offset(StatusCellMargin)
        }
        retweetedLable.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(backButton.snp_top)
            make.left.equalTo(backButton.snp_left).offset(StatusCellMargin)
        }
        pictureView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetedLable.snp_bottom).offset(StatusCellMargin)
            make.left.equalTo(retweetedLable.snp_left)
            make.width.equalTo(300)
            make.height.equalTo(90)
        }
        
    }
}